<?php 
    $this->headMeta()->appendHttpEquiv('Content-Type','text/html;charset=utf-8'); 
    $this->headTitle()->setSeparator(' - '); 
    $this->headTitle('Market'); 
    $auth = Zend_Auth::getInstance()->getIdentity();      
?>
<!DOCTYPE html>
<html lang="en">
	<head>
		<base href="<?php echo BASE_URL1;?>" />
		<meta charset="utf-8"/>
		<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
		<meta name="viewport" content="width=device-width, initial-scale=1"/>
		<meta name="description" content=""/>
		<meta name="author" content=""/>
		<link rel="icon" href="<?php echo BASE_URL ?>/static/images/favicon.ico"/>
		<?php echo $this->headMeta(); ?>
		<?php echo $this->headTitle(); ?>
        <!-- Jquery ui 1.11 -->
        <link href="<?php echo BASE_URL ?>/static/css/jquery-ui.min.css" rel="stylesheet"/>
        
        <link href="<?php echo BASE_URL ?>/static/css/jquery-ui.theme.min.css" rel="stylesheet"/>
        <link href="<?php echo BASE_URL ?>/static/css/jquery-ui-timepicker-addon.css" rel="stylesheet"/>
        <link href="<?php echo BASE_URL ?>/static/css/jquery.datetimepicker.css" rel="stylesheet"/>
		<!-- Bootstrap core CSS -->
		<link href="<?php echo BASE_URL ?>/static/css/bootstrap.min.css" rel="stylesheet"/>
        <!-- Simple sidebar -->
        <link href="<?php echo BASE_URL ?>/static/css/simple-sidebar.css" rel="stylesheet"/>
		<!-- Custom styles for this template -->
		<link href="<?php echo BASE_URL ?>/static/css/dashboard.css" rel="stylesheet"/>
		<!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
		<!--[if lt IE 9]>
			<script src="/static/js/ie8-responsive-file-warning.js">
			</script>
		<![endif]-->
		<link href="<?php echo BASE_URL ?>/static/css/style.css" rel="stylesheet"/>
		<link href="<?php echo BASE_URL ?>/static/css/style-responsive.css" rel="stylesheet"/>
        <!--<script src="<?php echo BASE_URL ?>/static/includes/ckeditor/ckeditor.js"></script>-->
		<script src="<?php echo BASE_URL ?>/static/js/ie-emulation-modes-warning.js">
		</script>
		<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
		<script src="<?php echo BASE_URL ?>/static/js/ie10-viewport-bug-workaround.js"></script>
        <script src="<?php echo BASE_URL ?>/static/js/nicEdit.js"></script>
       
		<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
		<!--[if lt IE 9]>
			<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js">
			</script>
			<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js">
			</script>
		<![endif]-->
        
        <script src="<?php echo BASE_URL ?>/static/js/jquery-1.11.1.min.js" type="text/javascript"></script>
		<script src="<?php echo BASE_URL ?>/static/js/jquery.cookie-1.4.1.js" type="text/javascript"></script>
		<script src="<?php echo BASE_URL ?>/static/js/jquery-ui.min.js" type="text/javascript"></script>
		<!--<script src="/static/js/jquery-ui-timepicker-addon.js" type="text/javascript"></script>-->
        <script src="<?php echo BASE_URL ?>/static/js/jquery.datetimepicker.js" type="text/javascript"></script>
		<!-- Jquery - end================================================-->
        
		<!-- Bootstrap core JavaScript - start================================================-->
		<script src="<?php echo BASE_URL ?>/static/js/bootstrap.min.js" type="text/javascript"></script>
		<!-- <script src="/static/js/docs.min.js" type="text/javascript"></script>-->
		<!-- Bootstrap core JavaScript - end==================================================-->
        
        <script src="<?php echo BASE_URL ?>/static/js/jquery.touchwipe.min.js" type="text/javascript"></script>
        
        <!-- Fancybox -->
        <script src="<?php echo BASE_URL ?>/static/addon/fancybox-2.1.5/jquery.mousewheel.pack.js" type="text/javascript"></script>
        <link href="<?php echo BASE_URL ?>/static/addon/fancybox-2.1.5/jquery.fancybox.css" rel="stylesheet" type="text/css" media="screen" />
        <script src="<?php echo BASE_URL ?>/static/addon/fancybox-2.1.5/jquery.fancybox.pack.js" type="text/javascript"></script>

        <script src="<?php echo BASE_URL ?>/static/js/jquery.touchwipe.min.js" type="text/javascript"></script>
		<script src="<?php echo BASE_URL ?>/static/js/script.js" type="text/javascript"></script>
	</head>
	<body>
		<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
			<div class="container-fluid">
                <div class="logo col-sm-3 col-md-2">
                    <a href="admin"><img class="img-responsive" src=" <?php echo BASE_URL ?>/static/images/anhbia.jpg" title="KPI Report" alt="KPI Report"/></a>
                    <span id="menu-toggle" href="#" class="btn btn-default glyphicon glyphicon-list hidden"><i class="icon-reorder"></i></span>
                    </div>
				<div class="navbar-header">
					<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
						<span class="sr-only">
							Toggle navigation
						</span>
						<span class="icon-bar">
						</span>
						<span class="icon-bar">
						</span>
						<span class="icon-bar">
						</span>
					</button>
				</div>
                <div class="navbar-menu">
                    <ul>
                        <li><a href="admin"><span class="glyphicon glyphicon-home"></span><span class="background background-green-1 glyphicon glyphicon-home"></span></a></li>
                        <li><a href="#"><span class="glyphicon glyphicon-envelope"></span><span class="background background-red-1 text">7</span></a></li>
                    </ul>
                </div>
				<div class="navbar-collapse collapse">
					<ul class="nav navbar-nav navbar-right">
						<li>
							<a href="admin/admin/info">Profile</a>
						</li>
                        <li>
							<a href="admin/admin/change">Đổi Pass</a>
						</li>
						<li>
							<a href="admin/auth/logout">Logout</a>
						</li>
					</ul>
				</div>
			</div>
		</div>
        <div class="clear"></div>
		<div class="container-fluid" id="wrapper">
        <?php
            $modelsAdmin=new Admin_Model_Admin();
            $dataUser=$modelsAdmin->getDataById($auth['adminId']);
            $modelProduct = new Admin_Model_Product();
            $modelCat = new Admin_Model_Productcat();            
            $waitList       = $modelProduct->getAllData(array('wait'=>1, 'type'=>'no'))->toArray();
            $waitVipList    = $modelProduct->getAllData(array('wait'=>1, 'type'=>'vi'))->toArray();                        
            $runList        = $modelProduct->getAllDataOnRun(array('wait'=>2))->toArray();            
            $expiredNoList  = $modelProduct->getAllData(array('wait'=>2,'type'=>'no','time'=>time()))->toArray();
            $expiredViList  = $modelProduct->getAllData(array('wait'=>2,'type'=>'vi','time'=>time()))->toArray();                        
            $catList        = $modelCat->getAllData()->toArray();
            
            $runProduct     = count($runList);
            $waitProduct    = count($waitList);
            $waitVipProduct = count($waitVipList);
            $expiredNo      = count($expiredNoList);
            $expiredVi      = count($expiredViList);
            $catProduct     = count($catList) ;  
             
            if(!isset($_COOKIE['checkMenu'])&& !$_COOKIE['checkMenu']!=0)   {
                setcookie("checkMenu", 0, time()+60000);
            }        
        ?>
			<div class="row">
				<div class="col-sm-3 col-md-2 sidebar">
                    <div class="avatar">
                        <img src="<?php echo (isset($dataUser['avatar']) && $dataUser['avatar']) ? BASE_URL.$dataUser['avatar'] : BASE_URL.'/static/images/user.png';?>" class="img-circle" onerror="this.onerror=null;this.src='public/static/images/noimage.jpg';"/>
                        <span><?php echo $auth['username'];?></span>
                        <a href="admin/auth/logout">Logout</a>
                    </div>
                    <ul class="sidebar-nav">                        
                        <li <?php if($_COOKIE['checkMenu']==0)echo 'class="active"';?>>
                             <span>
                                <span class='glyphicon glyphicon-cog'></span>
                                <span class='background background-red-1'></span>
                                <span class='text'><?php echo ($auth['role'] == 1)?'Admin':'Nhân Viên'?></span>
                             </span>
                             <ul <?php if($_COOKIE['checkMenu']==0)echo 'class="hidden"';?>>
                            <?php
                                if($auth['role'] == 1){
                            ?>                                                            
                                <li><a href="/admin/admin">
                                    <span class="glyphicon glyphicon-user"></span>
                                    <span class="background" style="left: -40px; background: yellow;"></span>
                                    <span class="text">Tài Khoản Quản Trị</span></a>
                                </li>
                                <li><a href="/admin/user">
                                    <span class="glyphicon glyphicon-user"></span>
                                    <span class="background" style="left: -40px; background: green;"></span>
                                    <span class="text">Quản Lý Người Dùng</span></a>
                                </li>                                
                                <li><a href="/admin/productcat">
                                    <span class="glyphicon glyphicon-th"></span>
                                    <span class="background" style="left: -40px; background: red;"></span>
                                    <span class="text">Danh Mục Rao Vặt Cấp 1</span>
                                    <span class="badge"><?=$catProduct?></span></a>                                    
                                </li>
                                <li><a href="/admin/productitem">
                                    <span class="glyphicon glyphicon-th-list"></span>
                                    <span class="background" style="left: -40px; background: orange;"></span>
                                    <span class="text">Danh Mục Rao Vặt Cấp 2</span></a>
                                </li>
                                <li><a href="/admin/product">
                                    <span class="glyphicon glyphicon-usd"></span>
                                    <span class="background" style="left: -40px; background: brown;"></span>
                                    <span class="text">Tin Rao Vặt</span>
                                    <span class="badge"><?php echo $runProduct?></span></a>                                    
                                </li>                                
                                <li><a href="/admin/product/wait">
                                    <span class="glyphicon glyphicon-pencil"></span>
                                    <span class="background" style="left: -40px; background: purple;"></span>
                                    <span class="text">Duyệt Tin Miễn Phí</span>
                                    <span class="badge"><?php echo $waitProduct?></span></a>
                                </li>
                                <li><a href="/admin/product/waitvip">
                                    <span class="glyphicon glyphicon-usd"></span>
                                    <span class="background" style="left: -40px; background: red;"></span>
                                    <span class="text">Duyệt Tin Vip</span>
                                    <span class="badge"><?php echo $waitVipProduct?></span></a>
                                </li>
                                <li><a href="/admin/product/expired">
                                    <span class="glyphicon glyphicon-th"></span>
                                    <span class="background" style="left: -40px; background: yellow;"></span>
                                    <span class="text">Tin Thường Hết Hạn</span>
                                    <span class="badge"><?php echo $expiredNo?></span></a>
                                </li>
                                 <li><a href="/admin/product/expiredvip">
                                    <span class="glyphicon glyphicon-usd"></span>
                                    <span class="background" style="left: -40px; background: Magenta;"></span>
                                    <span class="text">Tin Vip Hết Hạn</span>
                                    <span class="badge"><?php echo $expiredVi?></span></a>
                                </li>
                                <li><a href="/admin/area">
                                    <span class="glyphicon glyphicon-lock"></span>
                                    <span class="background" style="left: -40px; background: blue;"></span>
                                    <span class="text">Danh Mục Khu Vực</span></a>
                                </li>
                                <li><a href="/admin/mail">
                                    <span class="glyphicon glyphicon-envelope"></span>
                                    <span class="background" style="left: -40px; background: Aqua;"></span>
                                    <span class="text">Template gởi mail</span></a>
                                </li>
                            <?php 
                                }else{
                            ?>
                                <li><a href="/admin/product">
                                    <span class="glyphicon glyphicon-pencil"></span>
                                    <span class="background" style="left: -40px; background: yellow;"></span>
                                    <span class="text">Duyệt Tin Miễn Phí</span></a>
                                </li> 
                                <li><a href="/admin/product/waitvip">
                                    <span class="glyphicon glyphicon-pencil"></span>
                                    <span class="background" style="left: -40px; background: purple;"></span>
                                    <span class="text">Duyệt Tin Vip</span>
                                    <span class="badge"><?=$waitProduct?></span></a>
                                </li>                           
                            <?php
                                }
                            ?>                                                          
                             </ul>
                        </li>
                    </ul>                                                                                                 
                </div>
				<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main main-content">
                    <?php echo $this->layout()->content; ?>
				</div>
			</div>
		</div>
		<!-- Jquery - start================================================-->

	</body>
</html>